﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DbMapping.Common;
using VideoCache.Server.Model;
using VideoCache.Server.BLL;

namespace VideoCache.Server.MVCWeb.Areas.Admin.Controllers
{
    public class ChannelUrlController : Controller
    {
        //
        // GET: /Admin/ChannelUrl/

        public ActionResult Index(string keyword, int page = 1)
        {
            int pageSize = 30;
            int recordCount = 0;

            Conditions cons = new Conditions();
            if (!string.IsNullOrEmpty(keyword))
            {
                cons.Add(new ConditionItem(LinkType.And, ChannelUrlTokenInfo.UrlField, CompareType.Container, keyword));
            }

            Orders orders = new Orders();
            orders.Add(new OrderItem(ChannelUrlTokenInfo.ChannelIdField, OrderDirection.Asc));

            var list = ChannelUrlTokenBLL.FindPage(cons, orders, page, pageSize, ref recordCount);

            ViewBag.Keyword = keyword;
            ViewBag.PageSize = pageSize;
            ViewBag.RecordCount = recordCount;

            return View(list);
        }

    }
}
